<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%
String path = request.getContextPath();
request.setAttribute("path", path);
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%>


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>提交订单</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/common/layui/css/layui.css"  media="all">



<link rel="stylesheet" href="/common/css/order/base.css" type="text/css">
<link rel="stylesheet" href="/common/css/order/global.css" type="text/css">
<link rel="stylesheet" href="/common/css/order/header.css" type="text/css">
<link rel="stylesheet" href="/common/css/order/fillin.css" type="text/css">
<link rel="stylesheet" href="/common/css/order/footer.css" type="text/css">

<script type="text/javascript" src="/common/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/common/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/common/js/order/cart2.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		//进行总价的计算
		var sum = 0.00;
		
		$(".pri").each(function(){
			//alert(sum);
			var pri = $(this).text();
			//alert(pri);
			sum += parseFloat(pri);
			
			
		});
		
		$(".priceCount").text(sum);
		
		$('input:radio:first').attr('checked', 'checked');
		
		
	})
	function noAddr(){
		alert("请添加收货地址");
	}
</script>

</head>
<body>
<!-- 顶部导航 start -->
	<div class="topnav">
		<div class="topnav_bd w990 bc">
			<div class="topnav_left">
				
			</div>
			<div class="topnav_right fr">
				<ul>
					<li>[<a href="login.html">${sessionScope.user.userId}</a>] [<a href="register.html">注销</a>]</li>
					<li class="line">|</li>
					<li><a href="/order/show">我的订单</a></li>
					

				</ul>
			</div>
		</div>
	</div>
	<!-- 顶部导航 end -->
	
	<div style="clear:both;"></div>
	
	<!-- 页面头部 start -->
	<div style="height:100px" align="center">
		
				<img src="/common/imge/logo.jpg" style="
					height: 100% ;display:inline;margin:0 auto";>
		
	</div>
	<!-- 页面头部 end -->
	
	<div style="clear:both;"></div>

	<!-- 主体部分 start -->
	<div class="fillin w990 bc mt15" style="border:1px solid #DDDDDD;background:#F9F7F7">
		<div class="fillin_hd">
			<h1>填写并核对订单信息</h1>
		</div>
<form action="/pay/payorder" method="post">
		<div class="fillin_bd">
			<div class="address_select none" style="display:inline">
					<ul>
					<fieldset class="layui-elem-field layui-field-title">
  							<legend>收货地址</legend>
					</fieldset>
					<c:choose>
					<c:when test="${fn:length(addrs) == 0}">
					<li><a href="/user/showaddress"  style="color:red">请添加收货地址</a></li>
					</c:when>
					<c:otherwise>
						<c:forEach items="${addrs}" var="addr">
							<li class="cur">
								<input type="radio" name="address" value="${addr.zyAid}"/>${sessionScope.user.userName} ${addr.shi } ${addr.qu } ${addr.juti} ${sessionScope.user.userPhone} 
								
							</li>
							
						</c:forEach>
						<li><a href="/user/showaddress">添加收货地址</a></li>
					</c:otherwise>	
					</c:choose>	
					</ul>	
				</div>
			</div>
			<!-- 收货人信息  end-->

			
			<!-- 商品清单 start -->
			<div class="goods" style="margin-left:20px;">
				<fieldset class="layui-elem-field layui-field-title">
  					<legend>商品信息</legend>
				</fieldset>
				
				<table>
					<thead>
						<tr>
							<th class="col1">商品</th>
							<th class="col2">规格</th>
							<th class="col3">价格</th>
							<th class="col4">数量</th>
							<th class="col5">小计</th>
						</tr>	
					</thead>
					<tbody>
					<input type="hidden" name ="orderId" value="${orders.orderId}"/>
					<c:forEach items="${orders.items}" var="item">
						
					
						<tr>
							<td class="col1"><a href="/product/pro?pid=${item.waresId}"><img src="http://localhost:8083/fileserver/wares/${item.imgpath }" alt="" /></a>  <strong><a href="/product/pid?pid=${item.waresId}">${item.waresName }</a></strong></td>
							<td class="col2"> <p>颜色： ${item.waresColor }</p> <p>型号： ${item.waresEdition }</p> </td>
							<td class="col3">￥  ${item.orderPrice/item.waresCount}</td>
							<td class="col4"> ${item.waresCount }</td>
							<td class="col5">￥<span class="pri"> ${item.orderPrice}</span></td>
						</tr>
						
						</c:forEach>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="5">
								<ul>
									<li>
									<%-- <input type="text" value="${sessionScope.orders }"> --%>
										<span>${fn:length(orders.items)} 件商品，总商品金额：￥</span>
										<em  class="priceCount"></em>
									</li>
									<li>
										<span>返现：</span>
										<em>￥0.00</em>
									</li>
									<li>
										<span>运费：</span>
										<em>￥0.00</em>
									</li>
									<li>
										<span>应付总额：￥</span>
										<em  class="priceCount"></em>
									</li>
								</ul>
							</td>
						</tr>
					</tfoot>
				</table>
				
			</div>
			<!-- 商品清单 end -->
		
		</div>
		<c:choose> <c:when test="${fn:length(addrs)!=0 }">
		<div class="fillin_ft center" style="margin:0 auto">
		<input type="submit" value="支付" style="background:orange; height: 100%;width:100px;color:white;float:right"/>
			<p>应付总额：￥<strong class="priceCount"></strong></p>
			
		</div>
		</c:when>
		<c:otherwise>
		<div class="fillin_ft center" style="margin:0 auto">
		
			
    			<button type="button" class="layui-btn layui-btn-danger" style="margin-top:5px;margin-right:5px">请设置收货地址</button>
		</div>
		</c:otherwise>
		</c:choose>
	</div>
	<!-- 主体部分 end -->
</form>
	<div style="clear:both;"></div>
	<!-- 底部版权 start -->
	<div class="footer w1210 bc mt15">
		<p class="links">
			<a href="">关于我们</a> |
			<a href="">联系我们</a> |
			<a href="">人才招聘</a> |
			<a href="">商家入驻</a> |
			<a href="">千寻网</a> |
			<a href="">奢侈品网</a> |
			<a href="">广告服务</a> |
			<a href="">移动终端</a> |
			<a href="">友情链接</a> |
			<a href="">销售联盟</a> |
			<a href="">论坛</a>
		</p>
		<p class="copyright">
			 © 2005-2013 JoinLabs网上商城 版权所有，并保留所有权利。  ICP备案证书号:京ICP证xxxxxx号 
		</p>
		<p class="auth">
			<a href=""><img src="/common/image/xin.png" alt="" /></a>
			<a href=""><img src="/common/image/kexin.jpg" alt="" /></a>
			<a href=""><img src="/common/image/police.jpg" alt="" /></a>
			<a href=""><img src="/common/image/beian.gif" alt="" /></a>
		</p>
	</div>
</body>
</html>